<!-- components/navigation/UserMenu.vue -->
<template>
  <div class="user-menu">
    <el-dropdown @command="handleCommand">
      <div class="user-info">
        <el-avatar :size="32" :icon="UserFilled" />
        <span class="username" v-if="!isMobile">平台管理员</span>
        <el-icon v-if="!isMobile"><arrow-down /></el-icon>
      </div>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item command="profile">
            <el-icon><User /></el-icon>
            个人中心
          </el-dropdown-item>
          <el-dropdown-item command="settings">
            <el-icon><Setting /></el-icon>
            系统设置
          </el-dropdown-item>
          <el-dropdown-item divided command="logout">
            <el-icon><SwitchButton /></el-icon>
            退出登录
          </el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </div>
</template>

<script setup lang="ts">
// @ts-nocheck
import { ref, computed } from 'vue'
import { useAppStore } from '@/stores/appStore'
import { 
  UserFilled, 
  ArrowDown, 
  User, 
  Setting, 
  SwitchButton 
} from '@element-plus/icons-vue'

const props = defineProps<{
  isMobile?: boolean
}>()

const appStore = useAppStore()

// 方法
const handleCommand = (command: string) => {
  switch (command) {
    case 'profile':
      console.log('个人中心')
      break
    case 'settings':
      console.log('系统设置')
      break
    case 'logout':
      console.log('退出登录')
      break
    default:
      break
  }
}
</script>

<style scoped>
.user-menu {
  display: flex;
  align-items: center;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.user-info:hover {
  background-color: var(--user-dropdown-hover, #f5f5f5);
}

.username {
  font-size: 14px;
  color: var(--header-text, #262626);
  white-space: nowrap;
}

/* 移动端适配 */
@media (max-width: 767px) {
  .username {
    display: none;
  }
}
</style>